package com.xiaowan.user.service;

import com.xiaowan.user.dao.UserMapper;
import com.xiaowan.user.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Description
 * @Author wbm
 * @Date 2019/11/18 0018 上午 09:29
 **/
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    /**
     * @Description 测试事务(我自己测试是无问题)
     * @Author wbm
     * @return java.lang.String
     **/
    @Override
    public String testTransactional() {
        userMapper.saveUser(4,"aabb");
        userMapper.saveUser(4,"bbcc");
        System.out.println("保存成功");
        return "test---success";
    }

    @Override
    public String testMapperXmlQuery() {
        User user = userMapper.selectUserByPrimaryKey(1);
        System.out.println(user.getName());
        return "test---success";
    }
}
